package com.stupro.cjlu.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.stupro.cjlu.common.vo.TeacherCourseItemVO;
import com.stupro.cjlu.common.vo.TeacherVO;
import com.stupro.cjlu.common.vo.TimetableItemVO;
import com.stupro.cjlu.entity.Teacher;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Administrator
 * @since 2021-05-10
 */
@Repository
public interface TeacherMapper extends BaseMapper<Teacher> {

    @Select("select count(*) from teacher ")
    Integer count(@Param("teaUserName")String teaUserName);

    IPage<TeacherCourseItemVO> getPage(IPage<TeacherCourseItemVO> page, @Param("departmentName")String departmentName, @Param("teaName") String teaName);

    List<TimetableItemVO> listTeacherTimetable(Integer teacherId);

//    List<TeacherCourseItemVO> listTeacherCourse(Integer teacherId);

    @Select("select t.*,c.coName,r.roName,coTime,coID from course c " +
            "left join teacher t on c.teaID  = t.teaID " +
            "left join room r on r.roID = c.roID " +
            "where teaName like '%${tName}%' and coName like '%${cName}%'" )
    IPage<TeacherCourseItemVO> selectCoursePage(IPage<TeacherCourseItemVO> page, @Param("tName")String tName,
                                               @Param("cName") String cName);

    @Select("select t.*,c.coName,r.roName,coTime,coID from course c " +
            "left join teacher t on c.teaID  = t.teaID " +
            "left join room r on r.roID = c.roID " +
            "where t.teaID = #{teaID} " )
    List<TeacherCourseItemVO> getCourseByTeacherId(@Param("teaID") int teaID);

    @Select("select count(*) " +
            "left join teacher t on c.teaID  = t.teaID " +
            "left join room r on r.roID = c.roID " +
            "where t.teaID = #{teaID} " )
    Integer countGetCourseByTeacherId(@Param("teaID") int teaID);
}
